#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 10;

int n, m;
int vis[N];
void f(int cnt, vector<int>& data) {
  if (cnt == n) {
    for (int x : data) cout << x << ' ';
    cout << endl;
    return;
  }
  rep(i, 1, n) {
    if (!vis[i]) {
      vis[i] = 1;
      data.push_back(i);
      f(cnt + 1, data);
      data.pop_back();
      vis[i] = 0;
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  vector<int> data;
  f(0, data);

  return 0;
}